package com.rz.htk.postal.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rz.htk.postal.entity.ExpressCodeRecord;
import com.rz.htk.postal.mapper.ExpressCodeRecordMapper;
import com.rz.htk.postal.service.IExpressCodeRecordService;
import com.rz.htk.product.service.IProductPriceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName ExpressCodeServiceImpl
 * @Description 快递单号service
 * @Author maweiyue
 * @Date 2019/3/27 18:42
 */
@Service
public class ExpressCodeRecordServiceImpl extends ServiceImpl<ExpressCodeRecordMapper, ExpressCodeRecord> implements IExpressCodeRecordService {

    private static Logger logger = LoggerFactory.getLogger("ExpressCodeRecordServiceImpl");

    @Resource
    RedisTemplate redisTemplate;

    @Resource
    IProductPriceService productPriceService;

    /**
     * 查询快递单号导入记录
     * @param expressCodeRecord
     * @return
     */
    public IPage<ExpressCodeRecord> getExpressCodeRecords(ExpressCodeRecord expressCodeRecord){
        QueryWrapper<ExpressCodeRecord> wrapper = new QueryWrapper();
        if (StringUtils.isNotEmpty(expressCodeRecord.getPrdCode())) {
            wrapper.like("prd_code", expressCodeRecord.getPrdCode());
        }
        if (StringUtils.isNotEmpty(expressCodeRecord.getExpressType())) {
            wrapper.like("express_type", expressCodeRecord.getExpressType());
        }
        wrapper.eq("express_code_id", expressCodeRecord.getExpressCodeId());
        Page<ExpressCodeRecord> page = new Page<>(expressCodeRecord.getPageNo(), expressCodeRecord.getPageSize());
        IPage<ExpressCodeRecord> desktopIPage = page(page, wrapper);
        return desktopIPage;
    }

}
